package com.daka.entity;

import lombok.Data;
import lombok.ToString;
import org.apache.ibatis.type.Alias;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 平台社团成员
 * Created by beliveli on 2016/5/29.
 */
@SuppressWarnings("unused")
@Data
@ToString
@Alias(value = "U_PLATFORM_GROUP_VOLUNTEER")
public class PlatformGroupVolunteer implements Serializable {
    private static final long serialVersionUID = 8549288031280021266L;
    private Long id;
    private Long platformId;
    private Long groupId;
    private Long volunteerId;
    private int status;
    private Date createTime;

    public static List<PlatformGroupVolunteer> build(int groupId, int platformId, List<GroupVolunteer> groupVolunteerList) {
        List<PlatformGroupVolunteer> platformGroupVolunteerList = new ArrayList<>();
        for (GroupVolunteer groupVolunteer : groupVolunteerList) {
            PlatformGroupVolunteer platformGroupVolunteer = PlatformGroupVolunteer.build(groupId, platformId, groupVolunteer.getStatus(), groupVolunteer.getVolunteerId());
            platformGroupVolunteerList.add(platformGroupVolunteer);
        }
        return platformGroupVolunteerList;
    }

    public static PlatformGroupVolunteer build(int groupId, int platformId, int status, int volunteerId) {
        PlatformGroupVolunteer platformGroupVolunteer = new PlatformGroupVolunteer();
        platformGroupVolunteer.setStatus(status);
        platformGroupVolunteer.setVolunteerId((long) volunteerId);
        platformGroupVolunteer.setGroupId((long) groupId);
        platformGroupVolunteer.setPlatformId((long) platformId);
        platformGroupVolunteer.setCreateTime(new Date());

        return platformGroupVolunteer;
    }
}
